
local alien = require 'alien'
local config = require 'config'

module (...)

local lib = alien.load(config.libgobject_path)

local GConnectFlags = 'int'
CONNECT_AFTER	= 1
CONNECT_SWAPPED	= 2

local function Func(name, types)
  local func = lib["g_"..name]
  func:types(types)
  _M[name] = func
  return func
end

GClosureNotify_types = {ret="void"; "pointer" --[[data]], "callback" --[[GClosure]]}
GCallback_types = {ret="void"}

Func("signal_connect_data", { ret=gulong;
  "pointer" --[[instance]],
  "string" --[[detailed_signal]],
  "callback" --[[GCallback]],
  "pointer" --[[data]],
  "pointer" --[[GClosureNotify]],
  GConnectFlags })

function signal_connect(instance, detailed_signal, c_handler, data)
  return signal_connect_data(instance, detailed_signal, c_handler, data, nil, 0)
end
